import CryptoJS from 'crypto-js'

/**
 * AES加密处理（CBC模式）
 */
export function encryptCBC(word, keyStr, ivStr) {
  keyStr = keyStr || 'abcdefgabcdefg12'
  ivStr = ivStr || '!@#$%asdfg12345'
  const key = CryptoJS.enc.Utf8.parse(keyStr)
  const iv = CryptoJS.enc.Utf8.parse(ivStr)
  const srcs = CryptoJS.enc.Utf8.parse(word)
  const encrypted = CryptoJS.AES.encrypt(srcs, key, {
    iv,
    mode: CryptoJS.mode.CBC,
    padding: CryptoJS.pad.ZeroPadding
  })
  return encrypted.toString()
}
